<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .a1 {
            width: 500px;
            height: 500px;
            background-color: red;
        }
    </style>
    <script src="./js1.js" defer></script>
</head>

<body>
    <div class="a1"></div>
    <!-- <script  type="module">
        let a=()=>{
            console.log(1);
        }
        import a from b;
    </script> -->
    <script>
        var countCollisions = function (directions) {
            let left = 0, result = 0;
            for (let i = 1; i < directions.length; i++) {
                if (directions[i] !== directions[left]) {
                    if (directions[left] === 'R' && directions[i] == 'L') {
                        result += (i - left) + 1;
                        directions = directions.slice(0,i)+'S'+directions.slice(i+1);
                    } else if (directions[left] === 'R' && directions[i] === 'S') {
                        result += (i - left);
                    } else if (directions[left] === 'S' && directions[i] === 'L') {
                        result += 1;
                        directions[i] = 'S';
                    }
                    left = i;
                }
            }
            return result;
        };
        "RLRSLL".split("");
        console.log(countCollisions("RLRSLL"));

        let a = 'LKJ';
        a = a.split("")
        a[0] = 'B'
        console.log(a);
    </script>
</body>

</html>